import com.exmple.service.impl.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserText {
    ClassPathXmlApplicationContext application=null;
    @Before
    public void before(){
       application=new ClassPathXmlApplicationContext("applicationContext.xml");
    }
    @Test
    public void getUser(){

        UserServiceImpl userService = application.getBean("userService", UserServiceImpl.class);
        userService.getUserById();
    }
    @Test
    public void  getUserId(){
        UserServiceImpl1 userServiceImpl1=application.getBean("userService1",UserServiceImpl1.class);
        userServiceImpl1.getUserById();
    }
    @Test
    public void  singleton(){
        UserServiceImpl2 userServiceImpl2=application.getBean("userService2", UserServiceImpl2.class);
        UserServiceImpl2 userServiceImpl21=application.getBean("userService2", UserServiceImpl2.class);
        userServiceImpl2.getUserById();
        userServiceImpl21.getUserById();
    }
    @Test
    public void byName(){
        UserServiceImpl3 userService = application.getBean("userService3", UserServiceImpl3.class);
        userService.getUserById();
    }
    @Test
    public void byType(){
        UserServiceImpl4 userService = application.getBean("userService4", UserServiceImpl4.class);
        userService.getUserById();
    }
    @Test
    public void lifecycle(){
        UserServiceImpl5 userService = application.getBean("userService5", UserServiceImpl5.class);
        userService.getUserById();
        application.destroy();
    }
    @Test
    public void lazy(){
//        UserServiceImpl6 userService = application.getBean("userService6", UserServiceImpl6.class);
//        userService.getUserById();

    }


}
